package register

import (
	"context"
	"github.com/hibiken/asynq"
	"mrshen_asynq_delay/internal/logic"
	"mrshen_asynq_delay/internal/svc"
)

type CronJob struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCronJob(ctx context.Context, svcCtx *svc.ServiceContext) *CronJob {
	return &CronJob{
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CronJob) Register() *asynq.ServeMux {
	mux := asynq.NewServeMux()
	//defer job
	mux.Handle("user:hello:asynq", logic.NewCloseHomestayOrderHandler(l.svcCtx))
	//queue job , asynq support queue job
	return mux
}
